package com.zhuiyun.project.api.frontuser.mapper;

import com.zhuiyun.project.api.frontuser.entity.FrontUser;
import com.zhuiyun.project.api.tag.entity.Tag;
import org.apache.ibatis.annotations.*;
import com.zhuiyun.project.common.mapper.BaseMapper;

import java.util.Date;
import java.util.List;

/**
 * @ClassName FrontUserMapper
 * @Description TODO
 * @Author XMY
 * @Date 2023/12/11 14:55
 **/
@Mapper
public interface FrontUserMapper extends BaseMapper<FrontUser>{
    /**
     * @Author XMY
     * @Description 根据id用户信息
     * @Date 2023/12/12 8:28
     * @Return
     * @param userId
     */
    List<FrontUser> getFrontUserById(Integer userId);
    /**
    * @Author LYX
    * @Description 根据用户名查询用户信息
    * @Date 2024/1/9 16:44
    */
    FrontUser getFrontUserByUserAccount(String userAccount);
    /**
     * @Author XMY
     * @Description 修改用户信息
     * @Date 2023/12/11 16:11
     * @Return
     * @param frontUser
     */
    int updateFrontUser(FrontUser frontUser);
    /**
     * @Author LYX
     * @Description 用户修改密码
     * @Date 2024/3/20 16:11
     * @Return
     * newPasswords //新密码
     * userId   //用户id
     */
    @Update("update front_user SET user_password = #{newPasswords} WHERE wx_openid = #{openid}")
    int updatePassword(String newPasswords,String openid);
    /**
     * @Author LYX
     * @Description 根据openid查询用户信息
     * @Date 2024/2/27 16:47
     */
    FrontUser getFrontUserByOpenId(String openid);
    /**
     * @Author LYX
     * @Description 微信登录（用户不存在）新增用户信息
     * @Date 2024/2/28 8:30
     */
    boolean insertFrontUser(FrontUser frontUser);
    /**
     * @Author XMY
     * @Description 根据用户id获取个性标签
     * @Date 2023/12/12 14:39
     * @Return
     * @param userId
     */
    @Select("select * from tag where id in (select tag_id from user_tag where user_id=#{userId})")
    List<Tag> getTagListByUserId(Integer userId);
    /**
     * @Author LYX
     * @Description 根据id添加微信唯一标识openid
     * @Date 2024/3/4 19:47
     */
    @Update("update front_user SET wx_openid = #{jg} WHERE id = #{id}")
    Boolean updateOpenid(Integer id, String jg);
    /**
     * @Author LYX
     * @Description 用户添加个性标签
     * @Date 2024/3/5 19:27
     */
    @Insert("INSERT INTO tag (tag_name) VALUES (#{tagName})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertTag(Tag tag);
    /**
     * @Author LYX
     * @Description 根据id查询frontUser
     * @Date 2024/3/6 8:47
     */
    @Select("select * from front_user where id = #{userId}")
    FrontUser getFrontUserByUserId(Integer userId);
    @Insert("INSERT INTO user_tag (user_id,tag_id) VALUES (#{userid},#{tagid})")
    Boolean insertUserTag(int userid, int tagid);
    /**
     * @Author LYX
     * @Description 用户添加邮箱
     * @Date 2024/3/8 8:50
     * @Return
     */
    Boolean updateEmail(String email,int userId);

    int updateEmail1(@Param("email") String email,
                    @Param("userId") int userId
    );

    FrontUser verifyEmail(String email);
    /**
     * @Author XMY
     * @Description 校验邮箱验证码
     * @Date 2023/12/13 14:22
     * @Return
     * @param email
     */
    List<FrontUser> getFrontUserEmailByEmail(String email);
    int delFrontUserById(Integer c);
    /**
     * @Author XMY
     * @Description 前端用户全查
     * @Date 2023/12/15 10:05
     * @Returnx
     * @param userName
     * @param phone
     * @param beginDate
     * @param endDate
     */
    List<FrontUser> getFrontUserList(@Param("userName") String userName,
                                     @Param("phone") String phone,
                                     @Param("beginDate") Date beginDate,
                                     @Param("endDate") Date endDate);
}
